
# -*- coding: utf-8 -*-

import json
from config import Config
from util.QRPredictor import QRPredictor
from util.FacialRecognition import predict
from controllers.BaseSocketController import BaseSocketController

class PredictController(BaseSocketController):
	def process(self, cv_image):
		if Config.STATE_TRAINING_MODEL:
			self.write_message('null')
		else:
			result = predict(cv_image)
			if result:
				self.write_message(json.dumps(result))
			else:
				result = QRPredictor.predict(cv_image)
				if result:
					self.write_message(json.dumps(result))
				else:
					self.write_message('null')
